import { defineStore } from 'pinia'
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
export const useLangStore = defineStore(
  'lang',
  () => {
    const i18n = useI18n()
    let language = ref<string>(localStorage.getItem('language') || 'zh')
    function setLanguage(lang: string) {
      language.value = lang
      localStorage.setItem('language', lang)
      i18n.locale.value = lang
    }
    return { language, setLanguage }
  },
  {
    persist: true
  }
)
